2020-2021 Sunseeker Telemetry and Lighting System
pmap_ex1_singleRuntimeConfig.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 //******************************************************************************
66 //******************************************************************************
67 #include "driverlib.h"
68 //*****************************************************************************
69 //
70 //Refer Datasheet for Port4 Port Mapping definitions
71 //
72 //*****************************************************************************
73 
74 const uint8_t port_mapping[] = {
75  //Port P4:
76  PM_TB0CCR0A,
77  PM_TB0CCR1A,
78  PM_TB0CCR2A,
79  PM_TB0CCR3A,
80  PM_TB0CCR4A,
81  PM_TB0CCR5A,
82  PM_TB0CCR6A,
83  PM_NONE
84 };
85 
86 void main (void)
87 {
88  //Stop WDT
89  WDT_A_hold(WDT_A_BASE);
90 
91  //Set DCO FLL reference = REFO
92  UCS_initClockSignal(
93  UCS_FLLREF,
94  UCS_REFOCLK_SELECT,
95  UCS_CLOCK_DIVIDER_1
96  );
97 
98  //VLO Clock Sources ACLK
99  UCS_initClockSignal(
100  UCS_ACLK,
101  UCS_REFOCLK_SELECT,
102  UCS_CLOCK_DIVIDER_1
103  );
104 
105 
106  //Set Ratio and Desired MCLK Frequency and initialize DCO
107  UCS_initFLLSettle(
108  1048,
109  32
110  );
111 
112  //Setup Port Pins
113  //P4.0 - P4.7 output
114  //P4.0 - P4.7 Port Map functions
115  GPIO_setAsPeripheralModuleFunctionOutputPin(
116  GPIO_PORT_P4,
117  GPIO_PIN0 + GPIO_PIN1 + GPIO_PIN2 +
118  GPIO_PIN3 + GPIO_PIN4 + GPIO_PIN5 +
119  GPIO_PIN6 + GPIO_PIN7 + GPIO_PIN8 +
120  GPIO_PIN9 + GPIO_PIN10 + GPIO_PIN11 +
121  GPIO_PIN12 + GPIO_PIN13 + GPIO_PIN14 +
122  GPIO_PIN15
123  );
124 
125  //CONFIGURE PORTS- pass the port_mapping array, start @ P4MAP01, initialize
126  //a single port, do not allow run-time reconfiguration of port mapping
127  PMAP_initPortsParam initPortsParam = {0};
128  initPortsParam.portMapping = port_mapping;
129  initPortsParam.PxMAPy = (uint8_t *)&P4MAP01;
130  initPortsParam.numberOfPorts = 1;
131  initPortsParam.portMapReconfigure = PMAP_DISABLE_RECONFIGURATION;
132  PMAP_initPorts(PMAP_CTRL_BASE, &initPortsParam);
133 
134 
135  //Start Up Down Timer
136  Timer_B_initUpDownModeParam initUpDownModeParam = {0};
137  initUpDownModeParam.clockSource = TIMER_B_CLOCKSOURCE_ACLK;
138  initUpDownModeParam.clockSourceDivider = TIMER_B_CLOCKSOURCE_DIVIDER_1;
139  initUpDownModeParam.timerPeriod = 256;
140  initUpDownModeParam.timerInterruptEnable_TBIE = TIMER_B_TBIE_INTERRUPT_DISABLE;
141  initUpDownModeParam.captureCompareInterruptEnable_CCR0_CCIE =
142  TIMER_B_CCIE_CCR0_INTERRUPT_DISABLE;
143  initUpDownModeParam.timerClear = TIMER_B_SKIP_CLEAR;
144  initUpDownModeParam.startTimer = true;
145  Timer_B_initUpDownMode(TIMER_B0_BASE, &initUpDownModeParam);
146 
147  //Generate PWM 1
148  Timer_B_initCompareModeParam param = {0};
149  param.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_1;
150  param.compareInterruptEnable = TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE;
151  param.compareOutputMode = TIMER_B_OUTPUTMODE_TOGGLE_SET;
152  param.compareValue = 192;
153  Timer_B_initCompareMode(TIMER_B0_BASE, &param);
154 
155  //Generate PWM 2
156  param.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_2;
157  param.compareInterruptEnable = TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE;
158  param.compareOutputMode = TIMER_B_OUTPUTMODE_TOGGLE_SET;
159  param.compareValue = 128;
160  Timer_B_initCompareMode(TIMER_B0_BASE, &param);
161 
162  //Generate PWM 3
163  param.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_3;
164  param.compareInterruptEnable = TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE;
165  param.compareOutputMode = TIMER_B_OUTPUTMODE_TOGGLE_SET;
166  param.compareValue = 96;
167  Timer_B_initCompareMode(TIMER_B0_BASE, &param);
168 
169  //Generate PWM 4
170  param.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_4;
171  param.compareInterruptEnable = TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE;
172  param.compareOutputMode = TIMER_B_OUTPUTMODE_TOGGLE_SET;
173  param.compareValue = 64;
174  Timer_B_initCompareMode(TIMER_B0_BASE, &param);
175 
176  //Generate PWM 5
177  param.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_5;
178  param.compareInterruptEnable = TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE;
179  param.compareOutputMode = TIMER_B_OUTPUTMODE_TOGGLE_SET;
180  param.compareValue = 32;
181  Timer_B_initCompareMode(TIMER_B0_BASE, &param);
182 
183  //Generate PWM 6
184  param.compareRegister = TIMER_B_CAPTURECOMPARE_REGISTER_6;
185  param.compareInterruptEnable = TIMER_B_CAPTURECOMPARE_INTERRUPT_DISABLE;
186  param.compareOutputMode = TIMER_B_OUTPUTMODE_TOGGLE_SET;
187  param.compareValue = 16;
188  Timer_B_initCompareMode(TIMER_B0_BASE, &param);
189 
190  //Enter LPM3
191  __bis_SR_register(LPM3_bits);
192 
193  //For debugger
194  __no_operation();
195 }
196 
MPU_initThreeSegmentsParam param
__no_operation()
void main(void)
const uint8_t port_mapping[]